package com.lwj.liwanjia.model;

import com.lwj.liwanjia.api.ApiService;
import com.lwj.liwanjia.bean.MarketDetailBean;
import com.lwj.liwanjia.utils.RetrofitHelper;

import rx.Subscriber;
import rx.android.schedulers.AndroidSchedulers;
import rx.schedulers.Schedulers;

/**
 * Created by Administrator on 2017/9/26.
 */

public class MarketDetailModel {
    public void getMarketDetailData(String type,  int shopInfoId, String goodsType, int sortType, String expressType, Subscriber<MarketDetailBean> subscriber) {
        if (type.equals("销量")) {
            RetrofitHelper.getSingleRetrofit()
                    .create(ApiService.class)
                    .getMarketDetailData( shopInfoId, goodsType)
                    .subscribeOn(Schedulers.io())
                    .observeOn(AndroidSchedulers.mainThread())
                    .subscribe(subscriber);
        } else if (type.equals("价格")) {
            RetrofitHelper.getSingleRetrofit()
                    .create(ApiService.class)
                    .getMarketDetailData1( shopInfoId, goodsType, sortType)
                    .subscribeOn(Schedulers.io())
                    .observeOn(AndroidSchedulers.mainThread())
                    .subscribe(subscriber);
        } else if (type.equals("好评度")) {
            RetrofitHelper.getSingleRetrofit()
                    .create(ApiService.class)
                    .getMarketDetailData2( shopInfoId, goodsType)
                    .subscribeOn(Schedulers.io())
                    .observeOn(AndroidSchedulers.mainThread())
                    .subscribe(subscriber);
        } else if (type.equals("筛选")) {
            RetrofitHelper.getSingleRetrofit()
                    .create(ApiService.class)
                    .getMarketDetailData3(shopInfoId, goodsType, expressType)
                    .subscribeOn(Schedulers.io())
                    .observeOn(AndroidSchedulers.mainThread())
                    .subscribe(subscriber);
        }
    }
}
